package org.andhy.formeasy.strategy;

import org.andhy.formeasy.core.ValidateItem;
import org.andhy.formeasy.valve.EnumValve;
import org.andhy.formeasy.valve.MaxValueValve;
import org.andhy.formeasy.valve.MinValueValve;
import org.andhy.formeasy.valve.MultipleValve;
import org.jdom.Element;


public class NumberStrategy extends BaseStrategy {

	private String name ;
	

	public ValidateItem build(Element paramElem) {
		vi.setPipeline(pipeline);
		vi.setName(paramElem.getAttributeValue("name"));
		if(paramElem == null ) return vi;
		Element multipleElem = paramElem.getChild(MultipleValve.IDENTIFY);
		if(null != multipleElem){
			pipeline.addValve(this.createMultipleValve(multipleElem));
		}
		
		pipeline.addValve(createEmptyValve(paramElem));
		
		
		Element maxElem = paramElem.getChild(MaxValueValve.IDENTIFY);
		if(null != maxElem){
			pipeline.addValve(this.createMaxValueValve(maxElem));
		}
		
		Element minElem = paramElem.getChild(MinValueValve.IDENTIFY);
		if(null != minElem){
			pipeline.addValve(this.createMinValueValve(minElem));
		}
		
		Element enumElem = paramElem.getChild(EnumValve.IDENTIFY);
		if(null != enumElem){
			pipeline.addValve(this.createMinValueValve(enumElem));
		}
		
		return vi;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

}
